<!--
 * @description: 文件描述
 * @version: 0.0.1
 * @author: xxx
 * @Date: 2025-02-27 09:57:16
-->
<script setup>
import { ref } from 'vue'
import { Setting } from '@element-plus/icons-vue'
import { useStore } from '@/store/useState'
import { useRouter } from 'vue-router'
const store = useStore()
const router = useRouter()
const onLogout = () => {
  store.deleteToken()
  router.push('/login')
}

const subimtDialogVisible = ref(false)
const emailDialogVisible = ref(false)
const onEditSubmit = () => {
  subimtDialogVisible.value = true
}
const onEditEmail = () => {
  emailDialogVisible.value = true
}
</script>

<template>
  <el-card body-style="padding:0;" class="header-card">
    <el-header class="header-container">
      <div class="logo-area">
        <img src="../assets/logo.png" alt="Logo" class="logo-image">
      </div>
      <div class="toolbar">
        <el-dropdown trigger="click">
          <div class="setting-icon">
            <el-icon>
              <setting />
            </el-icon>
          </div>
          <template #dropdown>
            <el-dropdown-menu class="header-dropdown">
              <el-dropdown-item @click="onLogout" class="dropdown-item">
                <span>退出登录</span>
              </el-dropdown-item>
              <el-dropdown-item @click="onEditSubmit" class="dropdown-item">
                <span>更改密码</span>
              </el-dropdown-item>
              <el-dropdown-item @click="onEditEmail" class="dropdown-item">
                <span>设置通知邮箱</span>
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
        <span class="welcome-text">欢迎登录</span>
      </div>
    </el-header>
  </el-card>
  <editSubmitDialog v-model="subimtDialogVisible" />
  <editEmiailDialog v-model="emailDialogVisible" />
</template>

<style scoped>
.header-card {
  margin-bottom: 1px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
  background: linear-gradient(to right, #ffffff, #f8f9fa);
}

.logo-area {
  display: flex;
  align-items: center;
}

.logo-image {
  width: 120px;
  height: auto;
  transition: transform 0.3s ease;
}

.logo-image:hover {
  transform: scale(1.05);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.setting-icon {
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #f5f7fa;
}

.setting-icon:hover {
  background-color: #e4e7ed;
  transform: rotate(90deg);
}

.welcome-text {
  font-size: 14px;
  color: #606266;
  font-weight: 500;
}

.header-dropdown {
  min-width: 120px;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.dropdown-item {
  padding: 8px 16px;
  font-size: 14px;
  transition: all 0.3s ease;
}

.dropdown-item:hover {
  background-color: #f5f7fa;
  color: #409eff;
}
</style>
